//! YoshiFlowCheck.debug.js
//

(function() {

Type.registerNamespace('Yoshi.Pages');

////////////////////////////////////////////////////////////////////////////////
// AlivenessCheckTheme

AlivenessCheckTheme = function AlivenessCheckTheme() {
    /// <field name="question" type="String" static="true">
    /// </field>
    /// <field name="poor" type="String" static="true">
    /// </field>
    /// <field name="ok" type="String" static="true">
    /// </field>
    /// <field name="great" type="String" static="true">
    /// </field>
}


Type.registerNamespace('YoshiFlowCheck');

////////////////////////////////////////////////////////////////////////////////
// AlivenessMap

AlivenessMap = function AlivenessMap() {
    AlivenessMap.initializeBase(this);
    this.add('title', 'Abe says, always take action from a place of excellent alignment. We can help you find an excellent vibration. How do you feel right now?');
    this.add('type', 'tri-bar');
    this.add('items', new DList().add(new DDict().add('title', 'A bit off').add('items', new DDict().add('title', 'Can you clarify exactly how you feel?').add('type', 'multi-list').add('items', new DList().add(new DDict().add('title', 'Frustration/Irritation/Impatience').add('items', '@done').end()).add(new DDict().add('title', 'Overwhelment').add('items', '@done').end()).add(new DDict().add('title', 'Revenge').add('items', new DDict().add('title', 'We suggest you play a game to elevate').add('type', 'multi-list').add('class', 'Larger').add('items', new DList().add(new DDict().add('title', 'Click to go to games page').add('items', '@page:GamesPage').end()).end()).end()).end()).end()).end()).end()).add(new DDict().add('title', 'Fairly good').add('items', new DDict().add('title', 'Can you clarify exactly how you feel?').add('type', 'multi-list').add('items', new DList().add(new DDict().add('title', 'Passion').add('items', '@done').end()).add(new DDict().add('title', 'Enthusiam/Eagerness/Happiness').add('items', '@done').end()).end()).end()).end()).add(new DDict().add('title', 'Most Excellent!').add('items', '@done').end()).end());
}


////////////////////////////////////////////////////////////////////////////////
// AlivenessCheck

AlivenessCheck = function AlivenessCheck(fn) {
    /// <param name="fn" type="Function">
    /// </param>
    /// <field name="_helpDict$3" type="Object">
    /// </field>
    /// <field name="_help$3" type="Help">
    /// </field>
    this._helpDict$3 = { 'class': 'AlivenessCheck', duration: 10000 };
    AlivenessCheck.initializeBase(this);
    new Await().loadCss('Scripts/Css/AlivenessCheck.css').addDx(ss.Delegate.create(this, function() {
        this.element = $("<div id='AlivenessCheck' class='FlowPath'/>").addClass(Type.getInstanceType(this).get_name() + ' AboveHider').appendTo('body');
        this._help$3 = new Help(this.element).after(5000, this._helpDict$3).every(30000, this._helpDict$3);
        new PathReader(new AlivenessMap().end(), { '@done': fn }, this._help$3).appendTo(this.element);
        this.element.position({ my: 'center', at: 'center', of: window.self });
        this.element.position({ my: 'top', at: 'top', of: window.self, offset: '0 200', collision: 'fit fit' });
    })).addAw(ss.Delegate.create(this, this.hiderAw), true).commit();
}
AlivenessCheck.prototype = {
    _help$3: null
}


Type.registerNamespace('YoshiFlowCheck.Classes');

////////////////////////////////////////////////////////////////////////////////
// PathReader

PathReader = function PathReader(path, vars, help) {
    /// <param name="path" type="Object">
    /// </param>
    /// <param name="vars" type="Object">
    /// </param>
    /// <param name="help" type="Help">
    /// </param>
    /// <field name="_help$3" type="Help">
    /// </field>
    /// <field name="_stack$3" type="Array">
    /// </field>
    /// <field name="_vars$3" type="Object">
    /// </field>
    this._stack$3 = [];
    PathReader.initializeBase(this);
    this._vars$3 = vars || {};
    this._help$3 = help || new Help(this.element);
    this.element = $("<div class='Path'/>");
    this._generatePath$3(path);
}
PathReader.prototype = {
    _help$3: null,
    _vars$3: null,
    
    _generatePath$3: function PathReader$_generatePath$3(path) {
        /// <param name="path" type="Object">
        /// </param>
        this._help$3.reset();
        this._stack$3.add(path);
        var type = path['type'];
        if (this._stack$3.length > 1) {
            $("<div class='BackBtn'/>").appendTo(this.element).html(Constants.leftMark).click(ss.Delegate.create(this, this._popPathEv$3));
        }
        if (type != null) {
            switch (type) {
                case 'tri-bar':
                    this._help$3.message = 'Click on the colored bar to make a choice.';
                    var items = path['items'];
                    ss.Debug.assert(items.length === 3, 'items.Count == 3');
                    $("<h3 class='Question'/>").appendTo(this.element).html(path['title']);
                    var bar = $("<div class='Bar'/>").appendTo(this.element);
                    $("<span class='Low'/>").appendTo(bar).html(items[0]['title']).data('next', ss.Delegate.create(this, function() {
                        this._generateItems$3(items[0]['items']);
                    })).click(ss.Delegate.create(this, this._clickItemEv$3));
                    $("<span class='Medium'/>").appendTo(bar).html(items[1]['title']).data('next', ss.Delegate.create(this, function() {
                        this._generateItems$3(items[1]['items']);
                    })).click(ss.Delegate.create(this, this._clickItemEv$3));
                    $("<span class='High'/>").appendTo(bar).html(items[2]['title']).data('next', ss.Delegate.create(this, function() {
                        this._generateItems$3(items[2]['items']);
                    })).click(ss.Delegate.create(this, this._clickItemEv$3));
                    break;
                case 'multi-list':
                    this._help$3.message = 'Click on a line to make a choice.';
                    var items = path['items'];
                    var dl = $('<dl/>').appendTo(this.element);
                    if (path['class'] != null) {
                        dl.addClass(path['class']);
                    }
                    $("<dt class='Question'/>").appendTo(dl).html(path['title']);
                    for (var i = 0; i < items.length; i++) {
                        var dd = $('<dd/>').appendTo(dl).html(items[i]['title']).click(ss.Delegate.create(this, this._clickItemEv$3));
                        this._addDataItem$3(dd, items, i);
                    }
                    break;
            }
        }
    },
    
    _addDataItem$3: function PathReader$_addDataItem$3(el, items, idx) {
        /// <param name="el" type="jQueryObject">
        /// </param>
        /// <param name="items" type="Array">
        /// </param>
        /// <param name="idx" type="Number" integer="true">
        /// </param>
        el.data('next', ss.Delegate.create(this, function() {
            this._generateItems$3(items[idx]['items']);
        }));
    },
    
    _generateItems$3: function PathReader$_generateItems$3(items) {
        /// <param name="items" type="Object">
        /// </param>
        if (typeof(items) === 'string') {
            var par = (items).split(':');
            switch (par[0]) {
                case '@page':
                    this.element.closest('.FlowPath').remove();
                    Cluster.hider(false);
                    var page = AllPages.page(par[1]) || par[1];
                    Master.GoPage(page);
                    break;
                default:
                    this.element.closest('.FlowPath').remove();
                    Cluster.hider(false);
                    var fn = this._vars$3[par[0]];
                    if (fn != null) {
                        fn();
                    }
                    break;
            }
            return;
        }
        this.element.empty();
        if ($.isArray(items)) {
            this._generatePath$3((items)[0]);
        }
        else {
            this._generatePath$3(items);
        }
    },
    
    _clickItemEv$3: function PathReader$_clickItemEv$3(e) {
        /// <param name="e" type="jQueryEvent">
        /// </param>
        var fn = $(e.target).data('next');
        fn();
    },
    
    _popPathEv$3: function PathReader$_popPathEv$3(e) {
        /// <param name="e" type="jQueryEvent">
        /// </param>
        var path = this._stack$3[this._stack$3.length - 2];
        this._stack$3.length = this._stack$3.length - 2;
        this.element.empty();
        this._generatePath$3(path);
    }
}


AlivenessCheckTheme.registerClass('AlivenessCheckTheme');
AlivenessMap.registerClass('AlivenessMap', DDict);
AlivenessCheck.registerClass('AlivenessCheck', Actor);
PathReader.registerClass('PathReader', Actor);
AlivenessCheckTheme.question = 'Abe says, always take action from a place of excellent alignment. We can help you find an excellent vibration. How do you feel right now?';
AlivenessCheckTheme.poor = 'A bit off';
AlivenessCheckTheme.ok = 'Pretty good';
AlivenessCheckTheme.great = 'Most excellent!' + ThemeBase.smile;
})();

//! This script was generated using Script# v0.7.4.0
